home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / ghostscript / src / gxdevmem.h < prev    next >
C/C++ Source or Header  |  1994-08-01  |  4KB  |  97 lines

  1. /* Copyright (C) 1989, 1991, 1992 Aladdin Enterprises.  All rights reserved.
  2.  
  3. This file is part of Ghostscript.
  4.  
  5. Ghostscript is distributed in the hope that it will be useful, but
  6. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  7. to anyone for the consequences of using it or for whether it serves any
  8. particular purpose or works at all, unless he says so in writing.  Refer
  9. to the Ghostscript General Public License for full details.
  10.  
  11. Everyone is granted permission to copy, modify and redistribute
  12. Ghostscript, but only under the conditions described in the Ghostscript
  13. General Public License.  A copy of this license is supposed to have been
  14. given to you along with Ghostscript so you can know your rights and
  15. responsibilities.  It should be in a file named COPYING.  Among other
  16. things, the copyright notice and this notice must be preserved on all
  17. copies.  */
  18.  
  19. /* gxdevmem.h */
  20. /* "Memory" device structure for Ghostscript library */
  21. /* Requires gxdevice.h */
  22.  
  23. /*
  24.  * A 'memory' device is essentially a stored bitmap.
  25.  * There are several different kinds: 1-bit black and white,
  26.  * 2-, 4-, and 8-bit mapped color, and 16-, 24-, and 32-bit true color.
  27.  * (16-bit uses 5/6/5 bits per color.  24- and 32-bit are equivalent:
  28.  * 24-bit takes less space, but is slower.)  All use the same structure,
  29.  * since it's so awkward to get the effect of subclasses in C.
  30.  *
  31.  * Regardless of the machine byte order, we store bytes big-endian:
  32.  * this is required if the bits will be used as the source for a
  33.  * rendering operation, and hardly costs anything to maintain.
  34.  */
  35. typedef struct gx_device_memory_s gx_device_memory;
  36. struct gx_device_memory_s {
  37.     gx_device_common;        /* (see gxdevice.h) */
  38.     gs_matrix initial_matrix;    /* the initial transformation */
  39.     uint raster;            /* bytes per scan line, */
  40.                     /* filled in by 'open' */
  41.     byte *base;
  42.     byte **line_ptrs;        /* scan line pointers */
  43.     /* Following is only needed for monochrome. */
  44.     int invert;            /* 0 if 1=white, -1 if 1=black */
  45.     /* Following are only needed for mapped color. */
  46.     int palette_size;        /* # of entries */
  47.     byte *palette;            /* RGB triples */
  48.     /* Following are used for all memory devices. */
  49.     gx_device *target;        /* (used for xfont procs) */
  50.     /* If the memory_procs are non-zero, they are used for */
  51.     /* allocating the bitmap when the device is opened, */
  52.     /* and freeing it when the device is closed. */
  53.     const gs_memory_procs *memory_procs;
  54. };
  55. extern const gx_device_memory
  56.     mem_mono_device,
  57.     mem_mapped2_color_device,
  58.     mem_mapped4_color_device,
  59.     mem_mapped8_color_device,
  60.     mem_true16_color_device,
  61.     mem_true24_color_device,
  62.     mem_true32_color_device;
  63.  
  64. /*
  65.  * Memory devices may have special setup requirements.
  66.  * In particular, it may not be obvious how much space to allocate
  67.  * for the bitmap.  Here is the routine that computes this
  68.  * from the width and height in the device structure.
  69.  */
  70. extern ulong gdev_mem_bitmap_size(P1(const gx_device_memory *));
  71. /*
  72.  * Compute the raster (bytes per line) similarly.
  73.  */
  74. #define gdev_mem_raster(mdev)\
  75.   gx_device_raster((const gx_device *)(mdev), 1)
  76.  
  77. /* Determine the appropriate memory device for a given */
  78. /* number of bits per pixel (0 if none suitable). */
  79. extern const gx_device_memory *gdev_mem_device_for_bits(P1(int));
  80.  
  81. /* Test whether a device is a memory device. */
  82. extern int gs_device_is_memory(P1(const gx_device *));
  83.  
  84. /* Ensure that the data bytes are in big-endian order. */
  85. /* This is only needed when the bitmap will be used as the source */
  86. /* for a copy_mono operation, and is only used for the character cache */
  87. /* and similar RAM-resident devices. */
  88. /* (Since we now always store data in big-endian order, */
  89. /* this operation is no longer necessary.) */
  90. extern void gdev_mem_ensure_byte_order(P1(gx_device_memory *));
  91.  
  92. /*
  93.  * A memory device is guaranteed to allocate the bitmap consecutively,
  94.  * i.e., in the form that can serve as input to copy_mono or copy_color
  95.  * operations (provided that the bytes are in big-endian order, of course).
  96.  */
  97.